﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.ExceptionServices;
using System.Text;
using System.Threading.Tasks;

namespace calculator
{
    internal class Program
    {
        static void Main(string[] args)
        {
            Program first = new Program();
            Console.WriteLine("请输入第一个数：");
            string num1=Console.ReadLine();
            double number1 = double.Parse(num1);
            Console.WriteLine("请输入第二个数：");
            double number2 = double.Parse(Console.ReadLine());
            Console.WriteLine("请输入运算符：+ - * /");
            string fh = Console.ReadLine();
            first.calcu(number1, number2, fh);

        }
        public void calcu(double num1,double num2,string fuhao)
        {
            double count;
             switch (fuhao)
                {
                    case  "+":
                        count = num2 + num1;
                        Console.WriteLine("您要计算的两数之和为:{0}", count);
                        break;
                    case "-":
                        count = num1 - num2;
                        Console.WriteLine("您要计算的值为:{0}", count);
                        break;
                    case "×":
                        count = num1 * num2;
                        Console.WriteLine("您要计算的值为:{0}", count);
                        break;
                    case "/":
                    if (num2 != 0)
                    {
                        count = num1 / num2;
                        Console.WriteLine("您要计算的值为:{0}", count);
                    }
                    else
                        Console.WriteLine("除数不能为0");
                        break;
                    default:
                        Console.WriteLine("请输入正确的运算符:(+ - * /)");
                        break;
                }
        }
           
                       
    }
}
       

